<?php
class Table_Acl_Role extends CF_Db_Table_Abstract
{
	protected $_name = '##_acl_roles';
	
	public function toTreeStore($parentId = 1)
	{
		# get root
		$where = 'parent_id' . (null == $parentId? ' IS NULL' : "=$parentId");
		$items = $this->select(array('id', 'text' => 'name'), $where)->getAll();
		foreach ($items as &$item) {
			$item['children'] = $this->toTreeStore($item['id']);
			$item['expanded'] = true;
		}
		
		return $items;
	}
}